//
//  RecommendNetWork.m
//  JKFuYinProject
//
//  Created by admin on 2018/6/6.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "RecommendNetWork.h"

//#import "LCFuYinIncomes.h"

//#define NetworkToolGET [[NetworkTool sharedInstance] POSTFuYinWithUrlString:urlString input:parameters success:^(NSDictionary *dict) {\
//if (successBlock) {\
//successBlock(dict);\
//}\
//} failure:^(NSError *error) {\
//if (failureBlock) {\
//failureBlock(error);\
//}\
//}];

#define NetworkToolPOST [[NetworkTool sharedInstance] POSTFuYinWithUrlString:urlString input:parameters success:^(NSDictionary *dict) {\
if (successBlock) {\
successBlock(dict);\
}\
} failure:^(NSError *error) {\
if (failureBlock) {\
failureBlock(error);\
}\
}];

@implementation RecommendNetWork

///剩余阅读领取的福音值次数 lingNumber
+ (void)PostLingNumberWithType:(NSString *)type action:(NSString *)action tid:(NSString *)tid success:(void (^)(NSDictionary *))successBlock failure:(void (^)(NSError *))failureBlock {
    
    NSString *urlString = [NSString stringWithFormat:@"%@%@"
                           ,http_toutiao,@"/task/fuyin"
                           ];
    if (1) {
        NSLog(@"urlString = %@", urlString);
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{@"type":type,@"action":action}];
    if (tid == nil) {
    }else{
        [parameters setObject:tid forKey:@"tid"];
    }
    NetworkToolPOST;
}

+ (void)loadLCBeautifulEssayControllerLingNumberDataWithSuccess:(void (^)(NSDictionary *))successBlock failure:(void (^)(NSError *))failureBlock  {
    
    NSString *urlString = [NSString stringWithFormat:@"%@%@"
                           ,http_zongSJUrl,@"/article/score_log"
                           ];
    if (1) {
        NSLog(@"urlString = %@", urlString);
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{}];
    
    NetworkToolPOST;
    
    
    /**[self PostLingNumberWithType:@"32" action:@"1" tid:nil success:^(NSDictionary *dict) {
     NSLog(@"dict = %@", dict);
     NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
     if (netWorkModel.status == 1) {
     NSDictionary *dic = netWorkModel.data;//dic
     LCFuYinIncomes *fuYinIncomes = [LCFuYinIncomes yy_modelWithJSON:dic];
     NSLog(@"fuYinIncomes.limit = %zd", fuYinIncomes.limit);
     [[NSNotificationCenter defaultCenter] postNotificationName:@"LCFuYinIncomesDidChangedNotification" object:self userInfo:@{@"limit":[NSString stringWithFormat:@"%zd",fuYinIncomes.limit]}];
     }else if (netWorkModel.status == 2) {
     [[NSNotificationCenter defaultCenter] postNotificationName:@"LCFuYinIncomesDidChangedNotification" object:self userInfo:@{@"limit":[NSString stringWithFormat:@"%d",200]}];
     }
     } failure:^(NSError *error) {
     NSLog(@"error = %@", error);
     }];*/
}

//- (void)addLCBeautifulEssayControllerLingCommentsIncomesDataWithTid:(NSString *)tid {
//    [self PostLingNumberWithType:@"32" action:@"6" tid:tid success:^(NSDictionary *dict) {
//        NSLog(@"dict = %@", dict);
//        NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
//        if (netWorkModel.status == 1) {
//            NSDictionary *dic = netWorkModel.data;//dic
//            LCFuYinIncomes *fuYinIncomes = [LCFuYinIncomes yy_modelWithJSON:dic];
//            [self showHud3WithTitle:[NSString stringWithFormat:@"%@",fuYinIncomes.title] :fuYinIncomes.tip];
//        }
////        else if(netWorkModel.status == 0){
////            [self showHud3WithTitle:[NSString stringWithFormat:@"%@",netWorkModel.msg] :@""];
////        }
//        else{
//            [SVProgressHUD showSuccessWithStatus:@"评论成功!"];
//            [SVProgressHUD dismissWithDelay:1];
//        }
//    } failure:^(NSError *error) {
//        NSLog(@"error = %@", error);
//    }];
//}

#pragma mark - tabbar 视频播放
+ (void)lc_PostVideoDataWithVideoId:(NSString *)videoId
               success:(void (^)(NSDictionary *))successBlock
               failure:(void (^)(NSError *))failureBlock
{
    //http://fuyin-api.app.inping.com/Movie/play
    NSString *urlString =
    [NSString stringWithFormat:@"%@%@"
                           ,http_zongSJUrl,@"/Movie/play"
                           ];
    if ((1)) {
        NSLog(@"urlString = %@", urlString);
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{@"id":videoId}];
    
    NetworkToolPOST;
    
}

+ (void)loadLCVideoDetailChangeHeaderControllerWithVideoId:(NSString *)videoId
                     success:(void (^)(LCMp4DetailModel *mp4DetailModel))successBlock
                     failure:(void (^)(NSError *))failureBlock
{
    [self lc_PostVideoDataWithVideoId:videoId success:^(NSDictionary *dict) {
        NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
        if (netWorkModel.status == 1) {
            LCMp4DetailModel *mp4DetailModel = [LCMp4DetailModel yy_modelWithJSON:netWorkModel.data];
            if  (successBlock) {
                successBlock(mp4DetailModel);
            }
        }else{
            if (failureBlock) {
                failureBlock(nil);
            }
        }
    } failure:^(NSError *error) {
        [LSZSpecialPackaging Reachability:^(NSString * strMessage) {
            if (failureBlock) {
                failureBlock(error);
            }
        }];
    }];
    
//    NSDictionary * diction = [[NSDictionary alloc]initWithObjectsAndKeys:id_id,@"id", nil];
//    NSString * url = [NSString stringWithFormat:@"%@/Movie/play",http_zongSJUrl];
//    [kNetworkTool POSTFuYinWithUrlString:url input:diction success:^(NSDictionary * dic) {
//        NSString * status = [NSString stringWithFormat:@"%@",dic[@"status"]];
//        if ([status isEqualToString:@"1"]) {
////            LSZIjkplayerPlayerManager * mg = [[LSZIjkplayerPlayerManager alloc]initWithIjkplayerPlayer:dic];
////            block(YES,@"ok",mg);
//        }else{
////            NSString * msg = [NSString stringWithFormat:@"%@",dic[@"msg"]];
////            block(NO,msg,nil);
//        }
//    } failure:^(NSError * error) {
//        [LSZSpecialPackaging Reachability:^(NSString * strMessage) {
//            if (failureBlock) {
//                failureBlock(error);
//            }
//        }];
//    }];
}
+ (void)lc_PostVideoSimilarityDataWithVideoId:(NSString *)videoId
                            success:(void (^)(NSDictionary *))successBlock
                            failure:(void (^)(NSError *))failureBlock
{
    //http://fuyin-api.app.inping.com/Movie/relevant
    NSString *urlString =
    [NSString stringWithFormat:@"%@%@"
     ,http_zongSJUrl,@"/Movie/relevant"
     ];
    if ((1)) {
        NSLog(@"urlString = %@", urlString);
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{@"id":videoId}];
    
    NetworkToolPOST;
}
+ (void)loadLCVideoWithListsViewControllerWithVideoId:(NSString *)videoId
                                                   success:(void (^)(NSArray<Mp4Detail *> *arrayData))successBlock
                                                   failure:(void (^)(NSError *))failureBlock
{
    [self lc_PostVideoSimilarityDataWithVideoId:videoId success:^(NSDictionary *dict) {
        NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
        if (netWorkModel.status == 1) {
            NSArray<Mp4Detail *> *arrayData = [NSArray yy_modelArrayWithClass:[Mp4Detail class] json:netWorkModel.data];
            if  (successBlock) {
                successBlock(arrayData);
            }
        }else{
            if (failureBlock) {
                failureBlock(nil);
            }
        }
    } failure:^(NSError *error) {
        [LSZSpecialPackaging Reachability:^(NSString * strMessage) {
            if (failureBlock) {
                failureBlock(error);
            }
        }];
    }];
}

+ (void)lc_PostVideoHomeDataWithSuccess:(void (^)(NSDictionary *))successBlock
                                  failure:(void (^)(NSError *))failureBlock
{
    //http://fuyin-api.app.inping.com/movie/home
    NSString *urlString =
    [NSString stringWithFormat:@"%@%@"
     ,http_zongSJUrl,@"/movie/home"
     ];
    if ((1)) {
        NSLog(@"urlString = %@", urlString);
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{}];
    
    NetworkToolPOST;
}
+ (void)loadLCRecommendCollectionWithSuccess:(void (^)(NSArray<LCRecommendHomeModel *> *arrayData))successBlock
                                      failure:(void (^)(NSError *))failureBlock
{
    [self lc_PostVideoHomeDataWithSuccess:^(NSDictionary *dict) {
        NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
        if (netWorkModel.status == 1) {
            NSArray<LCRecommendHomeModel *> *arrayData = [NSArray yy_modelArrayWithClass:[LCRecommendHomeModel class] json:netWorkModel.data];
            if  (successBlock) {
                successBlock(arrayData);
            }
        }else{
            if (failureBlock) {
                failureBlock(nil);
            }
        }
    } failure:^(NSError *error) {
        [LSZSpecialPackaging Reachability:^(NSString * strMessage) {
            if (failureBlock) {
                failureBlock(error);
            }
        }];
    }];
}
@end
